package me.huangxiang.design_pattern.command;

public class CommandApp {
    public static void main(String[] args){
        Light light = new Light(); // 命令的执行者
        Command lightOnCommand = new LightOnCommand(light); // 命令对象中保存命令的执行者
        Command lightOffCommand = new LightOffCommand(light);

        Stereo stereo = new Stereo();
        Command stereoOnCommand = new StereoOnCommand(stereo);
        Command stereoOffCommand = new StereoOffCommand(stereo);

        SimpleRemoteControl control = new SimpleRemoteControl(); // 命令的发送者
        control.setSlot(0, lightOnCommand, lightOffCommand);
        control.setSlot(1, stereoOnCommand, stereoOffCommand);
        control.onButtonClicked(0);
        control.offButtonClicked(0);
        control.onButtonClicked(1);
        control.offButtonClicked(1);

        Command noCommand = new NoCommand();
        for(int i = 2; i < 7; i++){
            control.setSlot(i, noCommand, noCommand);
        }

        control.onButtonClicked(4);
        control.offButtonClicked(6);
    }
}
